package main

import "fmt"

type Vertex struct {
	X int
	Y int
}

var (
	v1  = Vertex{1, 2}
	v2  = Vertex{X: 1}
	v3  = Vertex{}
	ppv = &Vertex{3, 4}
)

func main1() {
	i, j := 42, 2701
	p := &i
	fmt.Println(*p)
	*p = 21
	fmt.Println(i)

	p = &j
	*p = *p / 37
	fmt.Println(j)

	v := Vertex{1, 2}
	fmt.Println(v)
	fmt.Printf("V's type: %T\n", v)
	v.X = 4
	fmt.Println(v.X)

	pv := &v
	pv.X = 100
	fmt.Println(v.X)

	fmt.Println(v1, v2, v3, ppv)

	var a [2]string
	a[0] = "Hello"
	a[1] = "World"
	fmt.Println(a[0], a[1])
	fmt.Println(a)

	primes := [6]int{2, 3, 5, 7, 11, 13}
	fmt.Println(primes)

	var s []int = primes[1:4]
	fmt.Println(s)

	names := [4]string{
		"John",
		"Paul",
		"George",
		"Ringo",
	}

	fmt.Println(names)

	aa := names[0:2]
	bb := names[1:3]
	fmt.Println(aa, bb)

	bb[0] = "XXX"
	fmt.Println(aa, bb)
	fmt.Println(names)

	q := []int{2, 3, 5, 7, 11, 13}
	fmt.Println(q)
	printSlice(q)

	r := []bool{true, false, true, true, false, true}
	fmt.Println(r)

	ss := []struct {
		i int
		b bool
	}{
		{2, true},
		{3, false},
		{5, true},
		{7, true},
		{11, false},
		{13, false},
	}

	fmt.Println(ss)

	q = q[1:4]
	fmt.Println(q)
	printSlice(q)

	q = q[:2]
	fmt.Println(q)
	printSlice(q)

	q = q[1:]
	fmt.Println(q)
	printSlice(q)

	var ns []int
	fmt.Println(ns, len(ns), cap(ns))
	if ns == nil {
		fmt.Println("nil!")
	}
}

func printSlice(s []int) {
	fmt.Printf("--->> len = %d, cap = %d %v\n", len(s), cap(s), s)
}
